<template>
  <!-- <a-card title="节点附加单据" :bodyStyle="{paddingTop:'0px'}" size="small"> -->
    <k-form-build ref="kfd" :value="JSON.parse(taskData.appendForm.formJson)" :disabled="disabledAll" />
  <!-- </a-card> -->
</template>
<script>
import { getActKAppendFormData } from '@/api/process'
import { KFormBuild } from '@/components/k-form-design/index'
export default {
  name: 'nodeKdf',
  components: {
    KFormBuild
  },
  data() {
    return {
      processData: {
        formJson: {},
        formData: {},
        appendFormDataId: ''// 节点数据id
      }
    }
  },
  props: {
    taskData: {
      type: Object,
      default: () => {}
    },
    disabledAll: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    getKdfData() {
      return this.$refs.kfd.getData()
    },
    async getFormData() { // 获取附加节点数据
      try {
        const res = await getActKAppendFormData({
          nodeId: this.taskData.nodeId,
          processInstanceId: this.taskData.processInstanceId,
          processDefinitionId: this.taskData.processDefinitionId
        })
        if (res.success && res.result) {
          this.appendFormDataId = res.result.id
          this.$nextTick(() => {
            this.$refs.kfd.setData(JSON.parse(res.result.formData))
          })
        }
      } catch (err) {
        console.log(err)
      }
    }
  },
  mounted() {
    this.getFormData()
  }
}
</script>
